﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LicenserProduction
{
    public partial class TestLicenseForm : Form
    {
        public TestLicenseForm()
        {
            InitializeComponent();
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtLicenseFile.Text = openFileDialog1.FileName;
            }
        }


        private void btnTest_Click(object sender, EventArgs e)
        {
            LicenserAPI.Logic logic = new LicenserAPI.Logic();
            try
            {
                logic.IsValid(txtLicenseFile.Text, txtFeature.Text, txtPasscode.Text, true);
                MessageBox.Show("License is valid", "License check passed",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (LicenserAPI.Logic.LicenseException ex)
            {
                MessageBox.Show(ex.Message, "License check failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Close();
            }
        }
    }
}
